import com.wider.foundation.Buffered;
import com.wider.foundation.BufferingShim;
import java.util.Iterator;
import java.util.List;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author William Choi
 */
public class BufferedPrint implements Buffered {
    private BufferingShim shim;

    public BufferedPrint(){
        shim = new BufferingShim(3, 2000);
        shim.bindTo(this);
    }

    public void shutdown() throws InterruptedException{
        shim.shutdown();
    }
    
    public void printf(String line){
        shim.offer(line);
    }
    
    @Override
    public void flush(){
        shim.flush();
    }

    @Override
    public void process(Iterable buffer) {
        Iterator bufit = buffer.iterator();
        while(bufit.hasNext()){
            System.out.println(":: "  + (String) bufit.next());
        }
    }
}
